#import "CTNavigationController.h"
#import "CTBaseVC.h"
@interface CTNavigationController () <UIGestureRecognizerDelegate>
@end
@implementation CTNavigationController
-(instancetype)initWithRootViewController:(UIViewController *)rootViewController {
    if (self = [super initWithRootViewController:rootViewController]) {
        [self.navigationBar setTranslucent:NO];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    __weak typeof(self) weakself = self;
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.interactivePopGestureRecognizer.delegate = (id)weakself;
    }
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}
- (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated
{
    [super setNavigationBarHidden:hidden animated:animated];
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    if (gestureRecognizer == self.interactivePopGestureRecognizer) {
        BOOL var_prohibitReturn = YES;
        if ([self.viewControllers.lastObject isKindOfClass:[CTBaseVC class]]) {
            CTBaseVC *var_topVC = self.viewControllers.lastObject;
            var_prohibitReturn = var_topVC.var_prohibitReturn;
        }
        if (self.visibleViewController == [self.viewControllers objectAtIndex:0] || var_prohibitReturn) {
            return NO;
        }
    }
    return YES;
}
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.childViewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}
@end
